<?php include $this->getViewFile('/common/Head') ?>
<body class="J_scroll_fixed">
  <style type="text/css">
    .color{
      color:red;
    }
  </style>

  <div class="wrap J_check_wrap">
    <?php include $this->getViewFile('/common/Nav') ?>


     <!-- 搜索 -->
    <div class="h_a">查找</div>
    <?php $objForm = $this->beginWidget( 'CActiveForm', array('id' => 'searchForm','method' => 'get','action' => $this->createUrl('counttotal')) ); ?>
      <div class="search_type cc mb10">
           <div class="mb10">
        统计时间范围：
        <input type="text" name="start_time" class="input length_2 J_date" value="<?php echo $start_time?>" placeholder="选择起始时间">
        -
        <input type="text" class="input length_2 J_date" name="end_time" value="<?php echo $end_time?>" placeholder="选择结束时间">       
        <button class="btn">搜索</button>
          


          </div>
      </div>
    <?php $this->endWidget(); ?>


    <div class="mb10">
      统计结果
    </div>

    <form name="myform" action="" method="post" class="J_ajaxForm">
      <div class="table_list">
        <table width="100%" cellspacing="0">
          <thead>
            <tr>
              <td width="5%" align="center">类目</td>
              <td width="5%" align="center">审核人</td>
              <td width="5%" align="center">总销售额</td>
              <td width="5%" align="center">总销量</td>
              <td width="5%" align="center">定量</td>
              <td width="5%" align="center">完成单数百分比</td>
              <td width="5%" align="center">客单量</td>
            </tr>
          </thead>
          <tbody>



             <?php foreach($data as $cat_id => $rss){ ?>
             <?php $count = count($rss);$key = 0;$key1 = 0;?>
             <?php foreach($rss as $key => $rs){ ?>
              <tr data-admin_id="<?php echo $rs['admin_id']; ?>">
                <?php if($key == 0){ ?>
                <td  rowspan="<?php echo $count ?>" align="center"><?php echo $rs['name'] ?></td>
                <?php $key = 1;} ?> 


                  <td  align="center"><?php echo $rs['username'] ?></td>


                  <td  align="center"><?php echo $rs['sales'] ?></td>
                  <td  class="turnover" align="center"><?php echo $rs['turnover'] ?></td>
                  <td  class="quantify" align="center"><?php echo $rs['quantify'] ?></td>
                  <td  class="bili" align="center"></td>
                  <td  class="kedang" align="center"><?php echo $rs['single_quantity'] ?></td>

                
              </tr>
              <?php } ?>
             <?php } ?>

          </tbody>
        </table>

        
      </div>
    </form>


  </div>
  <script src="<?php echo $staticUrl; ?>statics/js/common.js"></script>
  <script type="text/javascript">
    var td_length = $("td").length;
    for(var i=0;i<td_length;i++){
      if($("td").eq(i).html() == ''){
        $("td").eq(i).html('0');
      }
    }

    //占比率
    var obj_tr = $("tr[data-admin_id]");
    var length = obj_tr.length;
    for(var i=0;i<length;i++){
      var obj_bili = obj_tr.eq(i).find('.bili').eq(0);
      var turnover = obj_tr.eq(i).find('.turnover').html();
      var quantify = obj_tr.eq(i).find('.quantify').html();
      if(parseInt(turnover) && parseInt(quantify)){
        var bili = ((turnover/quantify)*100).toFixed(2) + "%";
        console.log(bili);
        obj_bili.html(bili);
      }else{
        obj_bili.html('');
      }               
    }


  </script>
</body>
</html>